################################################################################
#### egs5raw import ############################################################
from _egs5 import *
from numpy import array
################################################################################
################################################################################



def block_set():
    blkset()
    
#def decod_xyz()    

def counters_out():
    cntout(0)
    
def list_media():
    print '--------------------------------------------------------------------'
    print ' [ media report ] '    
    lsmed()
    print #'--------------------------------------------------------------------'
    print     
    
def add_media(medname,chard):
    addmed(medname,chard)
    
def reset_media():
    rstmed()
    
def find_media(medname):
    return fndmed(medname)

def do_hatch():
    print '--------------------------------------------------------------------'
    print ' [ hatch report ] '        
    hatch()
    print #'--------------------------------------------------------------------'
    print       

def rand_set(inseed=1):
    luxlev=1
    print '--------------------------------------------------------------------'
    print ' [ hatch report ] '    
    rluxdat.luxlev=array(luxlev)
    rluxdat.inseed=array(inseed)
    rluxinit()
    print #'--------------------------------------------------------------------'
    print     


################################################################################
### list functions

def list_counters():
    
    dd=counters.__dict__
    print '--------------------------------------------------------------------'
    print ' [ in egs5.counters ] '
    for k in dd.keys():
        print '-- egs5.counters --> %12s ................ [ %i ] '%(k,dd[k])
    print #'--------------------------------------------------------------------'
    print
    
    
    
def list_regions():
    
    mxreg=misc.med.shape[0]
    
    print '--------------------------------------------------------------------'
    print ' [ region report ] '
    for ir in range(mxreg):
        if misc.med[ir]>0:
            print ' --> ir = %4i, med = %4i, ecut = %8.4f, pcut = %8.4f, rho = %8.4f'\
                %(ir,misc.med[ir],bounds.ecut[ir],bounds.pcut[ir],misc.rhor[ir])
    print '--------------------------------------------------------------------'
    print    
    
    
    
def list_iausfl():
    
    cc={0:'* Particle is going to be transported by distance TVSTEP',
        1:'* discard: ae<e<ecut or ap<e<pcut',
        2:'* discard: e<ae or e<ap',
        3:'* user requested discard',
        4:'* Part of particle energy deposited due to the binding energy',
        5:'Particle has been transported by distance TVSTEP',
        6:'A brem interaction is about to occur',
        7:'A brem interaction has just occurred',
        8:'A moller interaction is about to occur',
        9:'A moller interaction has just occurred',
        10:'A bhabha interaction is about to occur',
        11:'A bhabha interaction has just occurred',
        12:'An in-fight annihilation is about to occur',
        13:'An annihilation has just occurred', # maybe wrong
        14:'An At-rest  annihilation is about to occur',
        15:'A pair production is about to occur',
        16:'A pair production has just occurred',
        17:'A Compton interaction is about to occur',
        18:'A Compton interaction has just occurred',
        19:'A photoelectric interaction is about to occur',
        20:'A photoelectric interaction has just occurred',
        21:'UPHI entered',
        22:'UPHI exited ',
        23:'A coherent (Rayleigh) interaction is about to occur',
        24:'A coherent (Rayleigh) interaction has just occurred',
        25:'An EII interaction is about to occur',
        26:'An EII interaction has just occurred',
        27:'an energy hinge is about to occur in ELECTR',
        28:'an energy hinge has just occurred in ELECTR',
        29:'a msc hinge is about to occur in ELECTR',
        30:'a msc hinge has just occurred in ELECTR'}
    
    print '--------------------------------------------------------------------'
    print ' [ in egs5.epcont.iausfl ] '
    for iarg in range(31):
        print ' --> iarg = %3i, iausfl = %i,  '%(iarg,epcont.iausfl[iarg])+cc[iarg]
    print #'--------------------------------------------------------------------'
    print
    
    
################################################################################
### turn on flags
    
flagdict={
        'KL fluorescent photon'         :       edge2.iedgfl,
        'KL auger electron'             :       edge2.iauger 
        }
        
def turn_on(flag,ir):
    
    '''
    Turn on 'flag' option for certain region 'ir'
    
    Available flags:
        'KL fluorescent photon'         :       to ...
        'KL auger electron'             :       to ...
    '''
    
    flagdict[flag][ir]=1
    
def turn_off(flag,ir):
    
    '''
    Turn off 'flag' option for certain region 'ir'
    
    Available flags:
        'KL fluorescent photon'         :       to ...
        'KL auger electron'             :       to ...
    '''
    
    flagdict[flag][ir]=0    
    



